package flexo.examples;

import flexo.graphic.entity.Sprite;
import flexo.math.*;

public class Test_Graphic_Sprites extends Test_Graphic_Base
{
	flexo.scene.Node root;
	flexo.scene.Node spriteNode;
	flexo.scene.Node gridNode; 
	Sprite sonic;
	
	Vector position;
	Vector velocity;
	
	public static void main(String[] args)
	{
		run("flexo.examples.Test_Graphic_Sprites");
	}
	
	public void init()
	{
		super.init();
		
		position = new Vector();
		velocity = new Vector();
		
		root = mainScene.addChild("root");
		
		spriteNode = root.addChild("sprite");
		gridNode = root.addChild("grid");
		
		flexo.graphic.Material mat = graphic.addMaterial("gridMat", "textureRepeat");
		flexo.graphic.ShaderParam param = mat.getShaderParam("tex");
		param.setValue("textures/grid.png");
		param = mat.getShaderParam("repeatU");
		param.setValue(50.0f);
		param = mat.getShaderParam("repeatV");
		param.setValue(50.0f);
		
		flexo.graphic.entity.Entity grid = graphic.addQuad(50, 50);
		grid.setMaterial("gridMat");
		grid.attachTo(gridNode);
		gridNode.setRotation(new flexo.math.Quaternion(new flexo.math.Vector(1,0,0),-90.0f));
		gridNode.setPosition(new flexo.math.Vector(0,-1,0));
		
		sonic = graphic.addSprite("sprites/sonic.xml");
		
		flexo.graphic.Material matSonic = graphic.addMaterial("sprites/sonic","billboard");
		matSonic.setBlending(flexo.graphic.Material.Blending.TRANSPARENT_MASK);
		matSonic.getShaderParam("tex").setValue("sprites/sonic.png");
		sonic.setMaterial("sprites/sonic");
		
		sonic.setAnimation("run1");
		sonic.attachTo(spriteNode);	
		spriteNode.setPosition(new Vector(0,0,0));
	}

	public void cleanUp()
	{
	}	

	public void update()
	{
	}
}
